<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>

<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:if test="content.contentId==null"><s:text name="content.add.title"/></s:if><s:else><s:text name="content.edit.title"/></s:else></title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>
	<script type="text/javascript" src="${ctx}/js/jquery.progressbar.js"></script>
	<script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>

</head>
<body>
<div id="wrapper">
	<div class="curmb"><s:text name="your.site.position"/>:<a href="${ctx}/welcome.action"><s:text name="homepage"/></a><span>></span><s:text name="content.title"/></div>
	<div class="listtit"><p><span><strong><s:if test="pictureContent.contentId==null"><s:text name="content.add.title"/></s:if>
	<s:elseif test="cflag!=null&&cflag.equals(\"1\")">内容审核</s:elseif>
				<s:else><s:text name="content.edit.title"/></s:else> 
	</strong></span></p></div>
	<div class="listadd">
		<%-- <s:form action="content-upload"  enctype="multipart/form-data" method="post" onsubmit="return chkform()"> --%>
		<s:form action="picturecontent-save" id="save-form">
		<s:hidden name="cflag"/>
		<s:hidden name="pictureContent.contentId"/>
		<s:hidden name="pictureContent.category.categoryId"/>
		<s:hidden name="pictureContent.showType"/>
		<s:hidden name="pictureContent.isTop"/>
		<s:hidden name="contentAttach.attachId"/>
		<s:hidden name="contentAttach.attachMemo"/>
		<s:hidden name="content.contentStatus"/>
		<s:hidden name="content.publishSug"/>
		<s:hidden name="flag"/>
		<s:hidden name="topic.topicId"/>
		<table class="addgrid">
			<s:if test="topic.topicName!=null">
			<tr>
				<th><s:text name="content.cmsTopic"/>:</th>
				<td><s:property value="topic.topicName"/></td>
			</tr>
			</s:if><s:else>
			<tr>
				<th><s:text name="content.cmsCategory"/>:</th>
				<td><s:property value="pictureContent.category.catName"/></td>
			</tr>
			</s:else>
			<tr>
				<th><span id="contentDescriptionno" style="color:red">*</span><s:text name="content.contentTitle"/>:</th>
				<td><select name="showType_1"><option value="1">原创</option><option value="0">转载</option></select><s:textfield id="contentTitle" name="pictureContent.contentTitle" required="true" requiredposition="right" cssClass="txtin450"/><span id="contentTitleno"></span><a href="#this" onclick="addSimpleTitle()">*添加文章副标题</a><span id="catContentTitleAlert" style="color :red"><s:property value="pictureContent.category.catContentTitleAlert"/></span></td>
			</tr>
			<tr id="simpleT_1">
				<th>文章副标题:</th>
				<td><s:textfield id="content.simpleTitle1" name="pictureContent.simpleTitle1" cssClass="txtin450" onblur="simpleTitle1(this)"/><a href="#this" onclick="removeSimpleTitle('simpleT_1')">删除文章副标题</a></td>
			</tr>
			<tr id="simpleT_2">
				<th>文章副标题:</th>
				<td><s:textfield id="content.simpleTitle2" name="pictureContent.simpleTitle2" cssClass="txtin450" onblur="simpleTitle2(this)"/><a href="#this" onclick="removeSimpleTitle('simpleT_2')">删除文章副标题</a></td>
			</tr>
			<tr id="simpleT_3">
				<th>文章副标题:</th>
				<td><s:textfield id="content.simpleTitle3" name="pictureContent.simpleTitle3" cssClass="txtin450" onblur="simpleTitle3(this)"/><a href="#this" onclick="removeSimpleTitle('simpleT_3')">删除文章副标题</a></td>
			</tr>
			<tr>
				<th>自定义属性:</th>
				<td>
					<input type="checkbox" name="isTop_f">置顶</input>
					<input type="checkbox" name="showType_o">最新</input>
					<input type="checkbox" name="showType_o">推荐</input>
					<input type="checkbox" name="showType_o">精选</input>
					<input type="checkbox" name="showType_o">热点</input>
				</td>
			</tr>
			<tr>
				<th>是否允许评论:</th>
				<td>
					<s:if test="pictureContent.category.isComment">
						<s:select list="dicIsComment" value="pictureContent.isComment" name="pictureContent.isComment" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue"/>
					</s:if>
					<s:else>
						<s:select list="dicIsComment" value="pictureContent.category.isComment" name="pictureContent.isComment" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue" disabled="true" />
					</s:else>
				</td>
			</tr>
			<tr>
				<th><s:text name="content.contentAuthor"/>:</th>
				<td><s:textfield id="pictureContent.contentAuthor" name="content.contentAuthor" required="true" requiredposition="right" cssClass="txtin" onblur="contentAuthor(this)"/></td>
			</tr>
			<tr>
				<th><s:text name="key.words"/>:</th>
				<td><s:textfield id="keywords" name="pictureContent.keywords" required="true" requiredposition="right" cssClass="txtin"/><span id="keywordsno">多个关键字请以','隔开</span></td>
			</tr>
			<tr>
				<th><span id="contentDescriptionno" style="color:red">*</span><s:text name="content.contentDescription"/>:</th>
				<td><s:textarea id="contentDescription" onblur="checkDes()" name="pictureContent.contentDescription" required="true" requiredposition="right" cols="140" rows="4"/><span id="desPoint"></span></td>
			</tr>
			<tr>
				<th><s:text name="content.contentContext"/>:</th>
				<td><textarea id="contentContext" name="pictureContent.contentContext"><s:property value="pictureContent.contentContext"/></textarea>
					<ckeditor:replace  replace="pictureContent.contentContext" basePath="${ctx}/common/ckeditor/" /></td>
			</tr>
			<tr>
				<th><s:text name="content.contentTpl"/>:</th>
				<td>
					<s:if test="pictureContent.category.categoryId!=''"><s:select name="pictureContent.contentTpl" list="contenttpllist" /></s:if>
					<s:else><s:select name="pictureContent.contentTpl" list="toptpllist" /></s:else>
				</td>
			</tr>
			<tr>
				<th><span id="contentDescriptionno" style="color:red">*</span><s:text name="content.contentSource"/>:</th>
				<td><s:textfield id="contentSource" name="pictureContent.contentSource" required="true" requiredposition="right" cssClass="txtin"/><span id="contentSourceno"></span></td>
			</tr>
			<tr >
				<th><span id="pictureupload" style="color:red">*</span>上传图片</th>
				<td id="before">
					<div class="loadtit">请您选择图片的上传方式<span class="	">（单个文件上传大小不能超过2M）</span></div>
					<div class="loadmain">
						<div class="loadway">
							<input type="button" class="loadwaypic" onclick="up1()" onmousemove="$('input[name=uploadType]').val(1);document.getElementById('bester').style.pixelLeft=event.x-60;document.getElementById('bester').style.pixelTop=event.y-10;"/>
							<p>（文件格式必须为jpg/png/gif/jpeg）</p>
						</div>
						<div class="loadway">
							<input type="button" class="loadwayzip" onclick="up2()" onmousemove="$('input[name=uploadType]').val(2);document.getElementById('bester').style.pixelLeft=event.x-60;document.getElementById('bester').style.pixelTop=event.y-10;"/>
							<p>（文件压缩包格式必须为zip格式）</p>
						</div>
					</div>
				</td>
				<td id="uploads">
					
				</td>
			</tr>
			<s:if test="cflag!=null&&cflag.equals(\"1\")">
				<tr>
					<th>创建时间:</th>
					<td><s:date name="pictureContent.createTime" format="yyyy年MM月dd日 HH:mm:ss" /></td>
				</tr>
				<tr>
					<th>修改时间:</th>
					<td><s:date name="pictureContent.updateTime" format="yyyy年MM月dd日 HH:mm:ss" /></td>
				</tr>
				<tr>
					<th>发布时间:</th>
					<td><input name="pictureContent.publishTime" size="30" class="Wdate" id="qry_startTime_4" readonly="true"  value="<s:date name="pictureContent.publishTime" format="yyyy-MM-dd HH:mm:ss"/>"
							onFocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text"/></td>
				</tr>
				<tr>
					<th>发布类型:</th>
					<td>
						发布到：<s:select list="dicPublishType" value="pictureContent.publishType" name="pictureContent.publishType" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue"/></td>
				</tr>
				<tr>
					<th>操作日志:</th>
					<td><a href="#this" id="operLog">查看操作日志</a></td>
				</tr>
				<tr>
					<th>审核:</th>
					<td>
					<s:select list="dicAudit" value="pictureContent.contentStatus" onchange="publishView()" headerKey="" headerValue="--请选择--" name="pictureContent.contentStatus" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue"/>
					<span id="audit_status" style="color:red;display:none;">请选择!</span>
					</td>
				</tr>
				<tr>
					<th><s:text name="content.publishSug"/>:</th>
					<td><s:textarea cols="140" rows="4"  name="pictureContent.publishSug" required="true" requiredposition="right" /><span id="keywordssug" style="color:red">请输入审核意见!</span></td>
				</tr>
			</s:if><s:else>
				<tr>
					<th>创建时间:</th>
					<td><s:if test="pictureContent.createTime!=null"><s:date name="content.createTime" format="yyyy年MM月dd日 HH:mm:ss" /></s:if>
					</td>
				</tr>
				<tr>
					<th>修改时间:</th>
					<td>
						<s:if test="pictureContent.updateTime!=null"><s:date name="pictureContent.updateTime" format="yyyy年MM月dd日 HH:mm:ss" /></s:if>
					</td>
				</tr>
				<tr>
					<th>发布时间:</th>
					<td><input name="pictureContent.publishTime" size="30"  class="Wdate" id="qry_startTime_1" readonly="true"  value="<s:date name="pictureContent.publishTime" format="yyyy-MM-dd HH:mm:ss"/>"
							onFocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text"/></td>
				</tr>
				<tr>
					<th>审核:</th>
					<td> 
						<s:if test="pictureContent.contentStatus==1">审核通过</s:if>
						<s:elseif test="pictureContent.contentStatus==2">审核未通过</s:elseif>
						<s:else>未审核</s:else>
					</td> 
				</tr>
				<tr>
					<th>审核意见:</th>
					<td> <s:property  value="pictureContent.publishSug"  /></td>					 
				</tr>
				<tr>
					<th>发布类型:</th>
					<td>
						发布到：<s:select list="dicPublishType" value="pictureContent.publishType" name="pictureContent.publishType" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue"/></td>
				</tr>
			</s:else>
			<tr>
				<th>&nbsp;</th>
				<td>
				<s:if test="cflag!=null&&cflag.equals(\"1\")">
					<input type="button" value="<s:text name="save"/>" class="btnlist2" onclick="goAudit()"/>
					<s:if test="%{authLicence('3_3_4',pictureContent.category.categoryId)&&authLicence('3_3_2',pictureContent.category.categoryId)}">
				   		<input type="button" title="审核并发布文章" value="审核发布" disabled="disabled" class="btnlist2" id="savePublish"/>
				  </s:if>
				   <s:elseif test="%{authLicence('4_4_4',topic.topicId)&&authLicence('4_4_2',topic.topicId)}">
				  	<input type="button" title="审核并发布文章" value="审核发布" disabled="disabled" class="btnlist2" id="savePublish"/>
				  </s:elseif>
				</s:if>
					<s:elseif test="%{authLicence('3_3_3',pictureContent.category.categoryId)}">
					     <input type="button" value="<s:text name="save"/>" class="btnlist2" id="save"/>
					</s:elseif>
					<s:elseif test="%{authLicence('4_4_3',topic.topicId)}">
						 <input type="button" value="<s:text name="save"/>" class="btnlist2" id="save"/>
					</s:elseif>
					<s:else>
						 <input type="button" value="<s:text name="save"/>" class="btnlist2" id="save"/>
					</s:else>
				<s:if test="pictureContent.contentId==null"></s:if><s:else><input type="button" value="<s:text name="preview"/>" class="btnlist2" id="preview"/></s:else>
				<s:reset value="%{getText('reset')}" cssClass="btnlist2"/><input type="button" value="返回" class="btnlist2" onclick="javascript:history.go(-1);"/></td>
			</tr>
		</table>
		</s:form>
	</div>
</div>
<div id="lightbox" class="lightbox" >
	<div class="lighttit"><p><span><input type="button" value="&nbsp;" id="lightclose" class="lightclose" /><strong>操作日志</strong></span></p></div>
	<div class="lightmain">
		<div class="lightmaintit">操作日志查看</div>
		<div class="ilghtmainbox" style="OVERFLOW-y:auto;OVERFLOW:scroll;overflow-x:auto;">
			<div id="authorSetDiv" >
				<table class="listgridb" cellspacing="1" id="listbox">
					<tbody>
						<tr>
						 
							<th>时间</th>
							<th>IP地址</th>
							<th>用户</th>
							<th>操作</th>
		 
						</tr>
						<s:iterator value="operLogList">
							<tr>
							<td><s:property value="operTime"/>&nbsp;</td>
							<td><s:property value="operIp"/>&nbsp;</td>
							<td><s:property value="loginName"/>&nbsp;</td>
							<td><s:property value="operAct"/>&nbsp;</td>
							</tr>
						</s:iterator>
					</tbody>
				</table>
			</div>
		</div>
		<div class="lightbtnbox"><input type="button" value="确认" id="lightsubmit" class="btnlist2" onclick="authorSet()"/></div>
	</div>
</div>
<div id="lightbox1" class="lightbox">
	<div class="lighttit"><p><span><input type="button" value="&nbsp;" id="lightclose1" class="lightclose" /><strong>图片编辑</strong></span></p></div>
	<div class="lightmain">

		<div class="lightmaintit">图片列表</div>
		<div class="ilghtmainbox" id="editpiclist">
		</div>
		<div class="lightbtnbox">
			<input type="button" value="保存" id="lightsubmit1" class="btnlist2" />
			<input type="button" value="重置" onclick="resetMemo()" class="btnlist2" />
		</div>
	</div>
</div>
<form name="uploadForm" id="uploadForm"  method="post" enctype="multipart/form-data"  target='hidden_frame' style="width: 2px;height: 2px;overflow: hidden;">
<input name="uploadType" type="hidden"/>
				<div class="padding6-14">
					  <table align="center" width="100%" border="0" cellspacing="0" class="addgrid">
						<tr>
							<Th>上传附件:</th>
							<td>
								<input type='file' size='1' name='upload' value='上传' id='bester'   onchange='doSubmitSavePicture(this.value,this)' style="position:absolute;filter: Alpha(opacity=0);-moz-opacity:.0;opacity:0.0;" hidefocus/>
							</td>
						</tr>
						<tr>
							<th>附件</th>
							<td class='clearpm'></td>
						</tr>
						<iframe name='hidden_frame' id='hidden_frame' style='display:none'></iframe>
					</table>                   
				 </div>
		</form>
</body>
</html>
<script type="text/javascript" defer="defer">

			$("#preview").click(function(){
				var contentId = $("input[name=pictureContent.contentId]").val();
				window.open("${ctx}/generate/preview.action?targets="+contentId+"&type=content");
			});
			$("#operLog").click(function(){
				$$.shade("#operLog","#lightclose,#lightsubmit","#lightbox","600");
			});
			ajaxAction="${ctx}";
			
			var isNotSave=true;
			var tomp;
			window.onbeforeunload=function (){
			};
			window.onunload = function (){
				
				//文章解锁
				<s:if test="pictureContent.contentId!=null">
					if(isNotSave){
						$.post("content-ajaxunlock.action?content.contentId=<s:property value="pictureContent.contentId"/>&status=<s:property value="status"/>");
					}
				</s:if>
				
				//进行数据清除
				if($("input[name=pictureContent.contentId]").val()!=""&&$("#contentTitle").val()==""){
					var contentId = $("input[name=pictureContent.contentId]").val();
					$.ajax({	
						url:"${ctx}/content/picturecontent-delete.action?time="+new Date().getTime(),
						data:{"key":contentId},
						dataType:"text",
						success:function(data){
							
						},
						error:function(data){
							alert("删除失败");
						}
					});
				}
				tomp[0].removeChild(tomp[1]);
				tomp[0].removeChild(tomp[2]);
			};
			$("#contentTitle").blur(function(){
				var maxLen=100;
				var contentTitle=$("#contentTitle").val();
				
				 str = jQuery.trim(contentTitle);
				 document.getElementById("contentTitle").value=str;
				 
				contentTitle=$.trim(contentTitle);
				if((contentTitle==""||contentTitle.length==0)){
					$("#contentTitleno").html("文章标题不能为空");
					$("#contentTitleno").css("color","red");
				}
				if(contentTitle!=""){
					$("#contentTitleno").html("");
				}
				if ((contentTitle.length )> maxLen) {
					var ss=$("#contentTitle").val( $("#contentTitle").val().substr(0, maxLen) );
					$("#contentTitleno").html("文章标题过长");
					$("#contentTitleno").css("color","red");
				}
			});
			
			$("#keywords").blur(function(){
					var maxLen=100;
					var keywords=$("#keywords").val();
					 
					str = jQuery.trim(keywords);
					 document.getElementById("keywords").value=str;
					 
					keywords=$.trim(keywords);
					if ((keywords.length )> maxLen) {
						var ss=$("#keywords").val( $("#keywords").val().substr(0, maxLen) );
						$("#keywordsno").html("字符过长");
						$("#keywordsno").css("color","red");
					}
			});
			$("#contentSource").blur(function(){
				var maxLen=100;
				var contentSource=$("#contentSource").val();
				
				 str = jQuery.trim(contentSource);
				 document.getElementById("contentSource").value=str;
				 
				contentSource=$.trim(contentSource);
				if((contentSource==""||contentSource.length==0)){
					$("#contentSourceno").html("文章来源不能为空");
					$("#contentSourceno").css("color","red");
				}
				if(contentSource!=""){
					$("#contentSourceno").html("");
				}
				if ((contentSource.length )> maxLen) {
					var ss=$("#contentSource").val( $("#contentSource").val().substr(0, maxLen) );
					$("#contentSourceno").html("字符过长");
					$("#contentSourceno").css("color","red");
				}
		});
		$('#save').click(function(){
			var contentTitle = $("#contentTitle").val();
			var contentDescription = $("#contentDescription").val();
			var contentSource = $("#contentSource").val();
			if(contentTitle==""){
				alert('请输入文章标题');
				return false;
			}
			if(contentSource==""){
				alert('请输入文章来源');
				return false;
			}
			 if(contentDescription==""){
				alert('请输入简述内容');
				return false;
			}  
			 chkform(); 
		});
	$(document).ready(function() {
		
		<s:if test="cflag!=null&&cflag.equals(\"1\")">
		publishView();
		</s:if>
		
		<s:if test="pictureContent.simpleTitle1==null">
			$("#simpleT_1").hide();
		</s:if>
		<s:if test="pictureContent.simpleTitle2==null">
			$("#simpleT_2").hide();
		</s:if>
		<s:if test="pictureContent.simpleTitle3==null">
			$("#simpleT_3").hide();
		</s:if>
		if($('input[name=pictureContent.contentId]').val()!=''){
			listFile($('input[name=pictureContent.contentId]').val(),"picture");
		}
		//$("form[name=uploadForm]").hide();
		if($("input[name=pictureContent.isTop]").val()=="false"||$("input[name=pictureContent.isTop]").val()==""){
			$("input[name=isTop_f]").attr("checked","");
		}else{
			$("input[name=isTop_f]").attr("checked","checked");
		}
		var showType = $("input[name=pictureContent.showType]").val();
		$("select[name=showType_1]").val(showType.charAt(0));
		$("input[name=showType_o]").each(function(i){
			if(showType.charAt(i+1)=="1"){
				$(this).attr("checked","checked");
			}
		});
 
		$("#uploads").hide();
		$("#keywordssug").hide();
	});
	function up1(){
		$("input[name=uploadType]").val(1);
		//$("#uploadForm").show();
		$("#bester").click();
		//$("#uploadForm").hide();
	}
	function up2(){
		$("input[name=uploadType]").val(2);
		//$("#uploadForm").show();
		$("#bester").click();
		//$("#uploadForm").hide();
	}
	function chkform(){
		var pictureContentTitle = $("input[name=pictureContent.contentTitle]").val();
		var isUpload = $("#uploads").html();
		if(pictureContentTitle==""){
			alert("请输入文章标题！");
			return false;
		}
		if(isUpload==""){
			alert("请上传图片！");
			return false;
		}
		if($("input[name=attachId]").val()==null){
			alert("请上传图片！");
			return false;
		}
		if($("input[name=isTop_f]").attr("checked")==""){
			$("input[name=pictureContent.isTop]").val(false);
		}else{
			$("input[name=pictureContent.isTop]").val(true);
		}
		var showType = $("select[name=showType_1]").val();
		$("input[name=showType_o]").each(function(){
			if($(this).attr("checked")==""){
				showType+="0";
			}else{
				showType+="1";
			}
		});
		showType+="1";
		$("input[name=pictureContent.showType]").val(showType);
		var attachId  = "";
		var attachMemo = "";
		$("#loadPictureList").find("input[name=attachId]").each(function(){
			attachId+=$(this).val()+"@";
		});

		$("input[name=contentAttach.attachId]").val(attachId);
		$("input[name=contentAttach.attachMemo]").val(attachMemo);
		$("input[name=pictureContent.contentId]").val($("input[name=contentId]").val());
		var contentTitle=$("#contentTitle").val();
		isNotSave=false;		
		$("#save-form").submit();
	}
	
	
	$("#savePublish").click(function(){
		var contentTitle = $("#contentTitle").val();
		var contentDescription = $("#contentDescription").val();
		var contentSource = $("#contentSource").val();
		if(contentTitle==""){
			alert('请输入文章标题');
			return false;
		}
		if(contentSource==""){
			alert('请输入文章来源');
			return false;
		}
		 if(contentDescription==""){
			alert('请输入简述内容');
			return false;
		}  
		if($('select[name=pictureContent.contentStatus] option:selected').val()==''){
			$("#audit_status").show();
			return false;
		}		
		else if($('select[name=pictureContent.contentStatus] option:selected').val()==2){
			$("#audit_status").hide();
			if($("textarea[name=pictureContent.publishSug]").val()==""){
				$("#keywordssug").show();
				return false;
			}else{
				$("#keywordssug").hide();
			}
		}
		var pictureContentTitle = $("input[name=pictureContent.contentTitle]").val();
		var isUpload = $("#uploads").html();
		if(pictureContentTitle==""){
			alert("请输入文章标题！");
			return false;
		}
		if(isUpload==""){
			alert("请上传图片！");
			return false;
		}
		if($("input[name=attachId]").val()==null){
			alert("请上传图片！");
			return false;
		}
		if($("input[name=isTop_f]").attr("checked")==""){
			$("input[name=pictureContent.isTop]").val(false);
		}else{
			$("input[name=pictureContent.isTop]").val(true);
		}
		var showType = $("select[name=showType_1]").val();
		$("input[name=showType_o]").each(function(){
			if($(this).attr("checked")==""){
				showType+="0";
			}else{
				showType+="1";
			}
		});
		showType+="1";
		$("input[name=pictureContent.showType]").val(showType);
		var attachId  = "";
		var attachMemo = "";
		$("input[name=attachId]").each(function(){
			attachId+=$(this).val()+"@";
		});
		$("input[name=attachMemo]").each(function(){
			if($(this).val()!=""){
				attachMemo+= $(this).val()+"@";
			}else{
				attachMemo+= " @";
			}
		});
		$("input[name=contentAttach.attachId]").val(attachId);
		$("input[name=contentAttach.attachMemo]").val(attachMemo);
		$("input[name=pictureContent.contentId]").val($("input[name=contentId]").val());
		var contentTitle=$("#contentTitle").val();
		
		$("input[name='content.andPub']").remove();
		if(confirm("要同步更新栏目列表及首页吗?\n这样会使发布速度非常慢!\n点击[确定]发布栏目及首页!\n点击[取消]只发布文章!")){
			$("<input type='hidden' name='pictureContent.andPub' value='1'/>").appendTo("#save-form");
			tomp=$$.now_loading("正在发布栏目列表及首页...");
			isNotSave=false;
			$("#save-form").submit();
		}
		else{
			$("<input type='hidden' name='pictureContent.andPub' value='2'/>").appendTo("#save-form");
			tomp=$$.now_loading("正在发布文章...");
			isNotSave=false;
			$("#save-form").submit();
		}
	});
	
	
	function goAudit(){
		var contentTitle = $("#contentTitle").val();
		var contentDescription = $("#contentDescription").val();
		var contentSource = $("#contentSource").val();
		if(contentTitle==""){
			alert('请输入文章标题');
			return false;
		}
		if(contentSource==""){
			alert('请输入文章来源');
			return false;
		}
		 if(contentDescription==""){
			alert('请输入简述内容');
			return false;
		}  
		if($('select[name=pictureContent.contentStatus] option:selected').val()==''){
			$("#audit_status").show();
			return false;
		}		
		else if($('select[name=pictureContent.contentStatus] option:selected').val()==2){
			$("#audit_status").hide();
			if($("textarea[name=pictureContent.publishSug]").val()==""){
				$("#keywordssug").show();
				return false;
			}else{
				$("#keywordssug").hide();
			}
		}
		var cflag = $('select[name=pictureContent.contentStatus]').val();
		$("input[name=content.contentStatus]").val($("select[name=pictureContent.contentStatus] option:selected").val());
		$("input[name=content.publishSug]").val($("textarea[name=pictureContent.publishSug]").val());
		$('#cflag').val(cflag);
		chkform();
	}
	
	
	
	function initBar(){
		 $("#pb2").progressBar({ barImage: '../images/progressbg_yellow.gif'} );
		 $('#pb2').progressBar(1);
	}
	function percentBar(x){
		$('#pb2').progressBar(x);
	}
	function deletePic(){
		var ids = "";
		$("input[name=pic]:checked").each(function(){
			ids+=$(this).attr("id")+",";
		});
		if(ids!=""){
			delFile(ids,'picture');
		}
		setTimeout("listFile($('input[name=pictureContent.contentId]').val(),'picture')",500);
	}
	function checkAllPic(){
		if($("#checkallPic").attr("checked")){
			$("input[name=pic]").each(function(){
				$(this).attr("checked","checked");
			});
		}else{
			$("input[name=pic]").each(function(){
				$(this).attr("checked","");
			});
		}
		
	}
	function setFocusPic(){
		var s  = $("#uploads").find("input[name=pic]:checked").length;
		if(s<1){
			alert('请选择图片');
		}else if(s>1){
			alert('您只能设置一张图片为焦点图');
		}else{
			var obj = $("#uploads").find("input[name=pic]:checked")[0];
			var attachId = $(obj).attr("id"); 
			obj = $("#uploads").find("input[name=contentId]")[0];
			var contentId = $(obj).val();
			ajaxSetFocusPic(contentId, attachId);
		}
	}
	
	function ajaxSetFocusPic(contentId,attachId){
		$.ajax({
			async:false,
			url:'${ctx}/content/focus.action?t='+new Date().getTime(),
			data:{'contentId':contentId,'attachId':attachId},
			type:'post',
			dataType:'text',
			success:function(data){
				var json = eval('('+data+')'); 
				alert(json.msg);
				if(json.flag){
					$("#uploads").find("font[name=focus_mark]").each(function(i,item){
						$(item).remove();
					})
					var obj = $("#uploads").find("input[name=pic]:checked")[0] ;
					$(obj).after("<font color='red' name='focus_mark'>焦</font>");
				}
			}			
		});
	}
	
	function editPic(){
		$("#editpiclist").html("");
		var ids = "";
		$("input[name=pic]:checked").each(function(){
			ids+=$(this).attr("id")+",";
		});
		if(ids!=""){
			$.ajax({	
				url:"${ctx}/content/picturecontent-listpic.action?time="+new Date().getTime(),
				data:{"key":ids},
				dataType:"text",
				success:function(data){
					var str = "";
					var json = eval('('+data+')');
					var id = json.ids.split("@");
					var memo = json.memos.split("@");
					var size = json.sizes.split("@");
					var url = json.urls.split("@"); 					
					for(var i  = 0;i<id.length-1;i++){
						str+="<div class='editpiclist'>";
						str+="<div class='editpicnews fr'><ul>";
						if(memo[i]=="null"){
							str+="<li><label for='"+id[i]+"'>备注：</label><input id='"+id[i]+"' type='text' class='txtin' name='attachMemo'/></li>"
						}else{
							str+="<li><label for='"+id[i]+"'>备注：</label><input id='"+id[i]+"' type='text' class='txtin' name='attachMemo' value='"+memo[i]+"'/></li>"
						}
						
						str+="<li><label for='"+size[i]+"'>大小：</label>"+size[i]+"KB</li>";
						str+="<input name='attachId' type='hidden' value='"+id[i]+"'/>";
						str+="</ul></div>";
						str+="<div class='editpicbox fl'><img src='<s:property value="uploadUrl"/>"+url[i]+"' style='width: 104px;height: 90px'/></div>";
						str+="</div>";
					}
					$("#editpiclist").append(str);
				}
			});
		}
		$$.shade("#edit","#lightclose1,#lightsubmit1","#lightbox1","600");
	}
	
	function resetMemo(){
		$("#editpiclist").find("input[name=attachMemo]").each(function (){ 
			$(this).val('');
		});
	}
	
	$("#lightsubmit1").click(function(){
		var attachId  = "";
		var attachMemo = "";
		$("#editpiclist").find("input[name=attachId]").each(function(){
			attachId+=$(this).val()+"@";
		});
		$("#editpiclist").find("input[name=attachMemo]").each(function(){
			if($.trim($(this).val())!=""){
				attachMemo+= $(this).val()+"@";
			}else{
				attachMemo+= " @";
			}
		});
		$.ajax({	
			url:"${ctx}/content/picturecontent-savememo.action?time="+new Date().getTime(),
			data:{"contentAttach.attachId":attachId,
					"contentAttach.attachMemo":attachMemo},
			dataType:"text"
		});
	});
	function addSimpleTitle(){
		if($("#simpleT_1").attr("name")!="show"){
			$("#simpleT_1").attr("name","show");
			$("#simpleT_1").show();
		}else if($("#simpleT_2").attr("name")!="show"){
			$("#simpleT_2").attr("name","show");
			$("#simpleT_2").show();
		}else if($("#simpleT_3").attr("name")!="show"){
			$("#simpleT_3").attr("name","show");
			$("#simpleT_3").show();
		}else{
			alert("只可增加3个幅标题！");
		}
	}
	function removeSimpleTitle(obj){
		$("#"+obj).hide();
		$("#"+obj).attr("name","hide");
		$("#"+obj+" input").val('');
	}
	function inFile(base){
		var ids = "";
		$("input[name=pic]:checked").each(function(){
			ids+=$(this).attr("id")+",";
		});
		if(ids!=""){
			$.ajax({	
				url:"${ctx}/content/picturecontent-listpic.action?time="+new Date().getTime(),
				data:{"key":ids},
				dataType:"text",
				success:function(data){
					var str = "";
					var json = eval('('+data+')');
					var id = json.ids.split("@");
					var memo = json.memos.split("@");
					var size = json.sizes.split("@");
					var url = json.urls.split("@");
					var name = json.names.split("@");
					for(var i  = 0;i<id.length-1;i++){
						var ext = name[i].substring(name[i].lastIndexOf(".")+1,name[i].length);
						var str = "";
						str+="<img src='";
						str+=base+url[i];
						str+="' />";
						CKEDITOR.instances.contentContext.insertHtml(str);
					}
				}
			});
		}
	}
	
	//文章简述判空
	function checkDes(){
		var decCont =  $("#contentDescription").val();
		
		 str = jQuery.trim(decCont);
		 document.getElementById("contentDescription").value=str;
		 
		if(decCont == null  || decCont == ""){
			$("#desPoint").css("color","red");
			$("#desPoint").html("文章简述不能为空");
		}else{
			$("#desPoint").html("");
		}
	}
	
	
	function publishView(){
		var publishBtn = $("#savePublish");
		var s = $('select[name=pictureContent.contentStatus] option:selected').val();
		if(publishBtn.val()!='undefined'){
			if(s==1){
				publishBtn.attr("disabled",false);
				$("#audit_status").hide();
			}	
			else if(s==2){
				publishBtn.attr("disabled",true);
				$("#audit_status").hide();
			}
			else{
				publishBtn.attr("disabled",true);
				$("#audit_status").show();
			}
		}
			
	}
	
	function contentAuthor(str){
        str = jQuery.trim(str.value);
        document.getElementById("pictureContent.contentAuthor").value=str;
	}
   function simpleTitle1(str){
		 str = jQuery.trim(str.value);
		 document.getElementById("content.simpleTitle1").value=str;
   }
   function simpleTitle2(str){
		 str = jQuery.trim(str.value);
		 document.getElementById("content.simpleTitle2").value=str;
   }
   function simpleTitle3(str){
		 str = jQuery.trim(str.value);
		 document.getElementById("content.simpleTitle3").value=str;
   }
</script>